package com.xy.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.xiuye.util.cls.TypeUtil;


public class MainActivity extends AppCompatActivity {

    public static String EXTRA_MESSAGE = "com.xy.activity.MainActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        Toast.makeText(this,newConfig.orientation,Toast.LENGTH_LONG).show();

    }

    public void sendMessage(View view){
        Intent intent = new Intent(this,Main2Activity.class);
        String message = "Hello,I'm activity1.";
        intent.putExtra(EXTRA_MESSAGE,message);
        this.startActivity(intent);

    }

    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.example_menu, menu);
        return true;
    }

    public void onGroupItemClick(MenuItem item) {
        // One of the group items (using the onClick attribute) was clicked
        // The item parameter passed here indicates which item it is
        // All other menu item clicks are handled by <code><a href="/reference/android/app/Activity.html#onOptionsItemSelected(android.view.MenuItem)">onOptionsItemSelected()</a></code>
        Toast.makeText(this,item.getTitle(),Toast.LENGTH_LONG).show();
    }

}
